package com.example.adms.common.exception;

import cn.dev33.satoken.exception.NotLoginException;
import com.example.adms.vo.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
@ResponseBody
public class GlobalExceptionHandler {

    @ExceptionHandler(NotLoginException.class)
    public Result handleNotLoginException(NotLoginException e){
        return Result.fail(e.getCode(), e.getMessage());
    }
    @ExceptionHandler(ErrorVerifyException.class)
    public Result handleErrorVerifyException(ErrorVerifyException e){
        return Result.fail(400,e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public Result handleException(Exception e){
        return Result.fail(500,e.getMessage());
    }
}
